<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
	<!--通用的header-->
	<jsp:include page="/views/includes/base_header.jsp">
		<jsp:param value="商品类别管理" name="title"/>
	</jsp:include>
	
	<body>
		<!--导航条-->
		<jsp:include page="/views/includes/top_navbar.jsp"></jsp:include>
		
		<div class="container-fluid">
			<div class="row">
				<div class="col-md-2">
					<!--菜单栏-->		
					<jsp:include page="/views/includes/left_menu.jsp">
						<jsp:param value="dept_manage" name="active"/>
					</jsp:include>
				</div>
				<div class="col-md-1"></div>
				<div class="col-md-6">
					<div class="panel panel-primary">
						<div class="panel-heading">
						<c:if test="${litemallCategory==null}">
							添加商品类别
						</c:if>
						<c:if test="${litemallCategory!=null}">
							修改商品类别
						</c:if>	
						</div>
						<div class="panel-body"">
							
							<form  class="form-horizontal"  role="form" onsubmit="return false;">
								<!-- 作用域有商品类别信息，才设置id，当前为修改操作 -->
								<c:if test="${litemallCategory!=null}">
									<div class="form-group">
										<label for="id" class="col-sm-2 control-label">编号</label>
										<div class="col-sm-10">
											<input  id="id" name="id" readonly="readonly" 
											 type="text" class="form-control" 
											 value="${litemallCategory.id}"
											 >
										</div>
									</div>
								</c:if>
								
									<div class="form-group">
										<label for="name" class="col-sm-2 control-label">类目名称</label>
										<div class="col-sm-10">
											<input id="name" name="name"  type="text" 
												   class="form-control" 
												   placeholder="请输入类目名称"
												   value='${litemallCategory.name}'
												   >
										</div>
									</div>
									<div class="form-group">
										<label for="descInfo" class="col-sm-2 control-label">类目广告语介绍</label>
										<div class="col-sm-10">
											<input id="descInfo" name="descInfo"  type="text" 
												   class="form-control" 
												   placeholder="请输入类目广告语介绍"
												   value='${litemallCategory.descInfo}'
												   >
										</div>
									</div>
									<div class="form-group">
										<label for="type" class="col-sm-2 control-label">分类的类型（1平台特卖，2商家自营）</label>
										<div class="col-sm-10">
											<input id="type" name="type"  type="text" 
												   class="form-control" 
												   placeholder="请输入分类的类型（1平台特卖，2商家自营）"
												   value='${litemallCategory.type}'
												   >
										</div>
									</div>
									<div class="form-group">
										<label for="shopId" class="col-sm-2 control-label">门店id</label>
										<div class="col-sm-10">
											<input id="shopId" name="shopId"  type="text" 
												   class="form-control" 
												   placeholder="请输入门店id"
												   value='${litemallCategory.shopId}'
												   >
										</div>
									</div>
									<div class="form-group">
										<label for="iconUrl" class="col-sm-2 control-label">类目图标</label>
										<div class="col-sm-10">
											<input id="iconUrl" name="iconUrl"  type="text" 
												   class="form-control" 
												   placeholder="请输入类目图标"
												   value='${litemallCategory.iconUrl}'
												   >
										</div>
									</div>
									<div class="form-group">
										<label for="picUrl" class="col-sm-2 control-label">类目图片</label>
										<div class="col-sm-10">
											<input id="picUrl" name="picUrl"  type="text" 
												   class="form-control" 
												   placeholder="请输入类目图片"
												   value='${litemallCategory.picUrl}'
												   >
										</div>
									</div>
									<div class="form-group">
										<label for="level" class="col-sm-2 control-label"></label>
										<div class="col-sm-10">
											<input id="level" name="level"  type="text" 
												   class="form-control" 
												   placeholder="请输入"
												   value='${litemallCategory.level}'
												   >
										</div>
									</div>
									<div class="form-group">
										<label for="pid" class="col-sm-2 control-label">父类目ID</label>
										<div class="col-sm-10">
											<input id="pid" name="pid"  type="text" 
												   class="form-control" 
												   placeholder="请输入父类目ID"
												   value='${litemallCategory.pid}'
												   >
										</div>
									</div>
									<div class="form-group">
										<label for="sortOrder" class="col-sm-2 control-label">排序</label>
										<div class="col-sm-10">
											<input id="sortOrder" name="sortOrder"  type="text" 
												   class="form-control" 
												   placeholder="请输入排序"
												   value='${litemallCategory.sortOrder}'
												   >
										</div>
									</div>
									<div class="form-group">
										<label for="deleted" class="col-sm-2 control-label">逻辑删除</label>
										<div class="col-sm-10">
											<input id="deleted" name="deleted"  type="text" 
												   class="form-control" 
												   placeholder="请输入逻辑删除"
												   value='${litemallCategory.deleted}'
												   >
										</div>
									</div>
								
							
								<div class="form-group">
									<div class="col-sm-offset-2 col-sm-10">
										<button onclick="saveOrUpdateData()" class="btn btn-success">保存</button>
										<button type="reset"  class="btn btn-info">重置</button>
									</div>
								</div>
								
								
							 </form>
							
						</div>
						
					</div>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript">
	
	/**
		设置时期格式form表单
	*/
	
	
	/**
		添加或修改数据
	*/
	function saveOrUpdateData(){
		//是否保存的操作==没有id=id的input则会保存
		var isSaveOp=$("#id").size()==0;
		
		//设置添加或修改的url
		var opUrl=isSaveOp ?'/litemallCategory/save':'/litemallCategory/update';
		var opName=isSaveOp? '保存':'修改';
		//alert(opUrl);
		$.ajax({
			   type: "POST",
			   url: '${pageContext.request.contextPath}'+opUrl,
			   data: $("form").serialize(),
			   dataType:'json',
			   success: function(jsonObj){
				    if (jsonObj.status == 200) {
				    	//等待时间
				    	var time=1;
				    	Zxx.notice(opName+"成功！"+time+"秒无操作将回到查询界面");
						//清空信息
						if(isSaveOp){
							$("button[type='reset']").click()
						}
						//跳转到查询页面
						var goFindTimeOut= setTimeout(function() {
							window.location.href="${pageContext.request.contextPath}/litemallCategory/findListCusTypeByCondition";	
						}, time*1000);
						//如果再输入内容=自动停止跳转
						$('input').click(function(){
							clearTimeout(goFindTimeOut);
						});
					} else {
						Zxx.notice(opName+"失败！原因是：" + jsonObj.msg);
					} 
			   }
			});
	}
</script>

</html>